/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 * @flow
 */

import React, { Component } from 'react';
import {
  AppRegistry,
  StyleSheet,
  Text,
  View
} from 'react-native';
// import realm from './App/realm/user'
const Realm = require('realm');


class List extends Component {
    constructor(p){
        super(p);
        this.state = {};
        let users = [];
        // for(let i=1;i<=10;i++){
        //     users.push({
        //         name:'name'+i,
        //         id:i,
        //         tel:'tel'+i,
        //         qq:'qq'+i
        //     })
        // }
        // realm.write(()=>{
        //     realm.create('User',{
        //         name:'name1',
        //         id:1,
        //         qq:'qq1',
        //         tel:'tel1'
        //     })
        // })


    }
    componentDidMount(){
        // console.log(realm.objects('User'));
    }
    render() {
        let realm = new Realm({
            schema: [{name: 'Dog', properties: {name: 'string'}}]
        });

        realm.write(() => {
            realm.create('Dog', {name: 'Rex'});
        });

        return (
            <View style={styles.container}>
                <Text style={styles.welcome}>
                    Count of Dogs in Realm: {realm.objects('Dog').length}
                </Text>
            </View>
        );
    }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F5FCFF',
  },
  welcome: {
    fontSize: 20,
    textAlign: 'center',
    margin: 10,
  },
  instructions: {
    textAlign: 'center',
    color: '#333333',
    marginBottom: 5,
  },
});

AppRegistry.registerComponent('List', () => List);
